package com.up.vms.interfaces.rest.controller;

import com.up.jiasai.spring.annotation.LoginedAuth;
import com.up.vms.application.base.auth.UserSession;
import com.up.vms.application.service.ActivityApplicationService;
import com.up.vms.infrastructure.mvc.BaseResponse;
import com.up.vms.infrastructure.mvc.GeneRespDTO;
import com.up.vms.infrastructure.mvc.RespCode;
import com.up.vms.infrastructure.mvc.ReturnCode;
import com.up.vms.interfaces.rest.response.CommonResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(value = "App应用User入口", produces = "application/json")
@RequestMapping("/app/v1")
@Slf4j
public class AppUserController {

    @Autowired
    private ActivityApplicationService activityApplicationService;

    // 根据token获取用户信息

    // 根据token获取校验结果
    @RequestMapping(value = "/user/check", method = RequestMethod.GET)
    public BaseResponse activityInfo(@LoginedAuth UserSession userSession) {
        CommonResponse response = new CommonResponse();
        try {

            GeneRespDTO geneRespDTO = activityApplicationService.getUserInfo(userSession.getId());

            response.setRespCode(geneRespDTO.getRespCode());
            response.setData(geneRespDTO.getData());
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            response.setRespCode(new RespCode(ReturnCode.SERVICE_ERROR));
        }

        return response;
    }
}
